package com.woniu.aimd.config.ai.tools;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import com.woniu.aimd.mapper.UserMapper;

import com.woniu.aimd.pojo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    private UserMapper userMapper;

//   private static User user = (User) StpUtil.getSession().get("user");
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        List<String> permissionList = new ArrayList<>();
        User user = (User) StpUtil.getSession().get("user");
        System.out.println("获取权限列表 - 用户ID: " + loginId + ", 角色: " + user.getRole());
        if (user.getRole()==0){
            permissionList.add("ai");
            return permissionList;
        } else if (user.getRole()==1) {
            permissionList.add("ai");
            return  permissionList;
        }else{
            return new ArrayList<>();
        }
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        List<String> roleList = new ArrayList<>();
        User user = (User) StpUtil.getSession().get("user");
        System.out.println("当前用户角色："+user.getRole());
        if (user.getRole()==0){
            roleList.add("teacher");
            return roleList;
        }else if(user.getRole()==1){
            roleList.add("student");
            return roleList;
        }else {
            return new ArrayList<>();
        }
    }
}
